/*
 * Copyright 2006-2007 the original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.code.sant.supertask;

import org.apache.tools.ant.types.{FileSet => AntFileSet}
import java.io.File

import _root_.sant.Predef._

/**
 * @author Stepan Koltsov
 */
object FileSet {
  val empty = new FileSet(Nil)
  
	def file(f: File): FileSet = empty file f
  
  def dir(f: File): FileSet = empty dir f
  
  def test: FileSet = dir("sd").include("bebe")
}

/**
 * @author Stepan Koltsov
 */
class FileSet(params: Seq[AntParam]) {
  def toAntParam: AntParam = {
    Ant.fileset(params: _*)
  }
  
  def param(param: AntParam) = new FileSet(params ++ List(param))
  
  def dir(dir: File): FileSet = param("dir" -> dir)
  
  def file(file: File) = param("file" -> file)
  
  def includes(includes: String) = param("includes" -> includes)
  
  def includesFile(f: File) = param("includesfile" -> f)
  
  def excludes(excludes: String) = param("excludes" -> excludes)
  
  def excludesFile(f: File) = param("excludesfile" -> f)
  
  def include(name: String) = param(_root_.sant.Predef.include("name" -> name))
  
  def exclude(name: String) = param(_root_.sant.Predef.exclude("name" -> name))
}

